<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>分步表单-添加</title>
		<link rel="stylesheet" href="../../utils/layui/css/layui.css">
		<style>
			@charset "UTF-8";
			
			body {
			}
			
			.page_container {
				border: 1px solid #f2f2f2;
				border-radius: 5px;
				background-color: #ffffff;
				padding: 20px;
			}
			
			.page_container .zhongxian {
				opacity: 0.15;
			}
			
			.page_container .atitle {
				margin-left: 20px;
				padding: 0 10px;
				font-size: 20px;
				font-weight: 300;
			}
			.layui-layer-dialog .layui-layer-setwin{
				display: none;
			}
			.finder-image{
				width: 100%;
			}
			.finder-image-preview{
			float: left;
			max-width: 400px;
			background: #eee;
			overflow: hidden;
			position: relative;
			color: #000;
			cursor:pointer;
			min-width: 200px;
			margin-right: 8px;
			}
			.finder-image-preview .image-preview{
			color: #000;
			line-height: 200px;
			text-align: center;
			}
			.finder-image-button{
			width:20px;
			min-height:200px;
			float: left;
			background: #fff;
			overflow: hidden;
			padding-left: 1px;
			}
			.clone-one-image:hover{
				color: #FF0000;
			}
			.preview-text{
				padding-top: 3px;
				width: 100%; 
				overflow: hidden;
				background: #fff;
			}
			.preview-text-input{
				width: 100%;
				background: #fff;
				height: 28px;
				border: none;
			}
			.preview-text-input:hover{
				background-color: #d2d2d2;
			}
			.required{
				font-size: 16px;
				color: #f00;
				font-family: Tahoma;
				vertical-align: middle;
				margin-right: 2px;
				font-weight: 400;color: #f00;
				font-weight: 400;margin-right: 5px;
			}
			.layui-anim {
				z-index: 9999 !important;
			}
		</style>
		<link rel="stylesheet" href="../../utils/layui/css/layui.css">
		<script type="text/javascript" src="../../utils/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" src="../../utils/ueditor/ueditor.all.min.js"></script>
		<script type="text/javascript" src="../../utils/ueditor/lang/zh-cn/zh-cn.js"></script>
	</head>
	<body>
		<div id="view" type="text/html">
			<form class="layui-form" action=""  method="post"  onsubmit="return false;">
				<input id="_method" type="hidden" name="_method" value="PUT">
				<input type="hidden" name="_method_" id="_method_" value="" />
				<input type="hidden" name="toolbar" id="toolbar" value="row" />
				<div class="layui-tab" lay-filter="docDemoTabBrief">
				  <ul class="layui-tab-title" id="layui-tab-ul">
					{{#  arr_foreach(d.stepform_fields, function(index, item){ }}
					  <li id="layertab{{index}}" data-index="{{index}}"   class="{{#  if(index == 0){ }}layui-this{{#  } }}">{{ item.title }}</li>
				    {{#  }); }}
				  </ul>
				  <div class="layui-tab-content">
					{{#  arr_foreach(d.stepform_fields, function(index, item){ }}
					<div class="layui-tab-item{{#  if(index == 0){ }} layui-show {{#  } }}"   id="stepFormItem{{index}}" data-index="{{index}}">
						{{#  arr_foreach(item.field, function(key, value){ }}
						
							{{#  if(value.input_type == 'hidden'){ }}
								<input data-label="{{value.label}}" type="hidden" name="{{item.db_table}}[{{value.field}}]" maxlength="" placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" maxlength="{{value.input_maxlength}}" value="{{input_default(value.default)}}" data-tabinx="{{index}}">
								
							{{#  }else if(value.input_type == 'password'){ }}
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
							        <input data-label="{{value.label}}" type="password" name="{{item.db_table}}[{{value.field}}]" placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_default(value.default)}}" data-tabinx="{{index}}">
							      </div>
							    </div>
								
							{{#  }else if(value.input_type == 'radio'){ }}
							    <!--得保证value是有序数组--->
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
									  {{#  arr_foreach(value.value, function(k1, v1){ }}
										  {{#  if(k1 == value.default){ }}
											<input data-label="{{value.label}}" type="radio" name="{{item.db_table}}[{{value.field}}]" value="{{k1}}" title="{{v1}}" checked="" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">
										  {{# }else{ }}   
											<input data-label="{{value.label}}" type="radio" name="{{item.db_table}}[{{value.field}}]" value="{{k1}}" title="{{v1}}" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">
										  {{# } }} 
									  {{#  }); }}
							      </div>
							    </div>	
							{{#  }else if(value.input_type == 'checkbox'){ }}
							    <!--得保证value是有序数组--->
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
									  {{#  arr_foreach(value.value, function(k1, v1){ }}
										  {{#  if(in_array(k1, value.default)){ }}
											<input lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-label="{{value.label}}" type="checkbox" name="{{item.db_table}}[{{value.field}}][]" value="{{k1}}" title="{{v1}}" checked="" data-tabinx="{{index}}">
										  {{# }else{ }}   
											<input lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-label="{{value.label}}" type="checkbox" name="{{item.db_table}}[{{value.field}}][]" value="{{k1}}" title="{{v1}}" data-tabinx="{{index}}">
										  {{# } }} 
									  {{#  }); }}
							      </div>
							    </div>		
							{{#  }else if(value.input_type == 'number'){ }}
							    <!--得保证value是有序数组--->
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
									  <input data-label="{{value.label}}" type="number" name="{{item.db_table}}[{{value.field}}]"  maxlength="{{value.input_maxlength}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_default(value.default)}}" data-tabinx="{{index}}">
							      </div>
							    </div>	
							{{#  }else if(value.input_type == 'float'){ }}
							    <!--得保证value是有序数组--->
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
									  <input data-label="{{value.label}}" type="number" name="{{item.db_table}}[{{value.field}}]"  maxlength="{{value.input_maxlength}}"  min="{{value.input_min}}"  step="{{value.input_step}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required|number{{#  } }}" value="{{input_default(value.default)}}" data-tabinx="{{index}}">
							      </div>
							    </div>		
							{{#  }else if(value.input_type == 'select'){ }}
							    <!--得保证value是有序数组--->
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
									  <select data-label="{{value.label}}" name="{{item.db_table}}[{{value.field}}]" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">
									    <option value="">请选择</option>
									  {{#  arr_foreach(value.value, function(k1, v1){ }}
											{{#  if(is_avoidBrowser(v1)){ }}
													{{#  if(v1.key == value.default){ }}
														<option value="{{v1.key}}" selected="">{{v1.val}}</option>
													{{# }else{ }} 
														<option value="{{v1.key}}">{{v1.val}}</option>
													{{#  } }} 
											{{# }else{ }} 											
													{{#  if(k1 == value.default){ }}
													<option value="{{k1}}" selected="">{{v1}}</option>
													{{# }else{ }} 
													<option value="{{k1}}">{{v1}}</option>
													{{#  } }} 
											{{#  } }}
									  {{#  }); }}
									  </select>
							      </div>
							    </div>	
							{{#  }else if(value.input_type == 'color'){ }}
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
							        <input data-label="{{value.label}}" type="color" name="{{item.db_table}}[{{value.field}}]" value="{{input_default(value.default)}}" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}" style="height: 38px;width: 80px;" />
							      </div>
							    </div>	
							
							{{#  }else if(value.input_type == 'textarea'){ }}
							    <div class="layui-form-item">
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
									  <textarea data-label="{{value.label}}" name="{{item.db_table}}[{{value.field}}]" placeholder="请输入{{value.label}}" class="layui-textarea" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">{{input_default(value.default)}}</textarea>
							      </div>
							    </div>		
							{{#  }else if(value.input_type == 'image'){ }}
							    <div class="layui-form-item">
								  <input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">	
							      <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							      <div class="layui-input-block">
									  <div class="finder-image-preview" data-type="one-image">
										 
										{{#  if(value.defaultObj != ''){ }}
										<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;" onclick="cloneOneImage(this, '{{item.db_table}}[{{value.field}}]');">
											  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
										 </div>
										<!--隐藏域-->
										{{image_input(item.db_table+'['+value.field+']', value.defaultObj)}}
										<div class="image-preview" onclick="oneImageSelect(this, '{{item.db_table}}[{{value.field}}]');"><img alt="图片" src="{{value.defaultObj.url}}" height="200px"></div>
										<div class="preview-text" ><input readonly="readonly" title="{{value.defaultObj.original}}" class="preview-text-input" type="text" value="{{value.defaultObj.original}}"></div>
										{{# }else{ }}   
										<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneOneImage(this, '{{item.db_table}}[{{value.field}}]');">
											  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
										 </div>
										<input class="image_input"  name="{{item.db_table}}[{{value.field}}]" value="" type="hidden"  />
										<div class="image-preview" onclick="oneImageSelect(this, '{{item.db_table}}[{{value.field}}]');">请选择一张图片</div>
										<div class="preview-text" ></div>
										{{# } }} 
									  </div>
							      </div>
							    </div>	
							{{#  }else if(value.input_type == 'images'){ }}
							    <div class="layui-form-item">
								  <input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">
								  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
								  <div class="layui-input-block">
									  
									  <!----循环----->
									  {{#  if(value.defaultObj != ''){ }}
										  {{#  arr_foreach(value.defaultObj, function(k1, v1){ }}
										  <div class="finder-image">
											<div class="finder-image-preview" data-type="more-image">
												 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;" onclick="cloneMoreImage(this, '{{item.db_table}}[{{value.field}}]');">
													  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
												  </div>
												{{image_input(item.db_table+'['+value.field+']'+"[]", v1)}}  
												<div class="image-preview" onclick="moreImageSelect(this, '{{item.db_table}}[{{value.field}}]');"><img alt="图片" src="{{v1.url}}" height="200px"></div>
												<div class="preview-text" ><input readonly="readonly" title="{{v1.original}}" class="preview-text-input" type="text" value="{{v1.original}}" /></div>
											</div>
										  </div>
										  {{#  }); }}
									  {{# }else{ }}   
									  <div class="finder-image">
									  	<div class="finder-image-preview" data-type="more-image">
									  		 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneMoreImage(this, '{{item.db_table}}[{{value.field}}]');">
									  			  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
									  		  </div>
									  		
									  		<input class="image_input"  name="{{item.db_table}}[{{value.field}}][]" value="" type="hidden"  />
									  		<div class="image-preview" onclick="moreImageSelect(this, '{{item.db_table}}[{{value.field}}]');">请选择一张或多张图片</div>
									  		<div class="preview-text" ></div>
									  	</div>
									  </div>
									  {{# } }} 
										
										
								  </div>
								</div>	
								{{#  }else if(value.input_type == 'video'){ }}
								    <div class="layui-form-item">
									  <input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">	
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											<div class="finder-image-preview" data-type="one-video">
												
												
												{{#  if(value.defaultObj != ''){ }}
												<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;" onclick="cloneOneImage(this, '{{item.db_table}}[{{value.field}}]');">
													  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
												  </div>
												
												{{image_input(item.db_table+'['+value.field+']', value.defaultObj)}}
												<div class="image-preview" onclick="oneVideoSelect(this, '{{item.db_table}}[{{value.field}}]');"><img alt="缩略图" src="{{value.defaultObj.thumbnail}}" height="200px"></div>
												<div class="preview-text" ><input readonly="readonly" title="{{value.defaultObj.original}}" class="preview-text-input" type="text" value="{{value.defaultObj.original}}" /></div>
												{{# }else{ }}   
												<div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneOneImage(this, '{{item.db_table}}[{{value.field}}]');">
													  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
												  </div>
												
												<input class="image_input"  name="{{item.db_table}}[{{value.field}}]" value="" type="hidden"  />
												<div class="image-preview" onclick="oneVideoSelect(this, '{{item.db_table}}[{{value.field}}]');">请选择一个视频</div>
												<div class="preview-text" ></div>
												{{# } }} 
												
												
											</div>
									  </div>
									</div>	
								{{#  }else if(value.input_type == 'videos'){ }}
								    <div class="layui-form-item">
									  <input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">	
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											{{#  if(value.defaultObj != ''){ }}
											
											  {{#  arr_foreach(value.defaultObj, function(k1, v1){ }}
											  <div class="finder-image">
											  	<div class="finder-image-preview" data-type="more-video">
											  		 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneMoreImage(this, '{{item.db_table}}[{{value.field}}]');">
											  			  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
											  		  </div>
											  		
											  		{{image_input(item.db_table+'['+value.field+']'+"[]", v1)}}  
											  		<div class="image-preview" onclick="moreVideoSelect(this, '{{item.db_table}}[{{value.field}}]');"><img alt="缩略图" src="{{v1.thumbnail}}" height="200px"></div>
											  		<div class="preview-text" ><input readonly="readonly" title="{{v1.original}}" class="preview-text-input" type="text" value="{{v1.original}}" /></div>
											  	</div>
											  </div>
											  {{#  }); }}
											  
											{{# }else{ }}   
											<div class="finder-image">
												<div class="finder-image-preview" data-type="more-video">
													 <div class="clone-one-image" style="position: absolute; right: 5px; top:5px; z-index: 99;display: none;" onclick="cloneMoreImage(this, '{{item.db_table}}[{{value.field}}]');">
														  <i class="layui-icon layui-icon-close-fill" style="font-size: 24px;"></i>
													  </div>
													
													<input class="image_input"  name="{{item.db_table}}[{{value.field}}][]" value="" type="hidden"  />
													<div class="image-preview" onclick="moreVideoSelect(this, '{{item.db_table}}[{{value.field}}]');">请选择一个或多个视频</div>
													<div class="preview-text" ></div>
												</div>
											</div>
											
											{{# } }} 
									  </div>
									</div>	
								{{#  }else if(value.input_type == 'audio'){ }}
								    <div class="layui-form-item">
									  <input data-label="{{value.label}}"  id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">	
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											<div>
											  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    
												  {{#  if(value.defaultObj != ''){ }}
												  <li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{value.defaultObj.original}}
												  {{image_input(item.db_table+'['+value.field+']', value.defaultObj)}}
												  <i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:this.parentNode.parentNode.removeChild(this.parentNode);document.getElementById('validation-{{item.db_table}}[{{value.field}}]').value='';">ဆ</i></li>
												  {{# } }} 
											  </ul>
											  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="oneAudioSelect(this, '{{item.db_table}}[{{value.field}}]')">浏览</button>
											</div>
									  </div>
									</div>	
								{{#  }else if(value.input_type == 'audios'){ }}
								    <div class="layui-form-item">
									  <input data-label="{{value.label}}"  id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">	
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											<div>
											  <ul class="layui-tab-title" style="border: 1px solid #eee;  min-height:22px; height: auto; overflow: hidden; width:70%;float:left; padding: 8px;">    
											  
												{{#  if(value.defaultObj != ''){ }}
													{{table_input(item.db_table+'['+value.field+']'+"[]", value.defaultObj)}}  
												{{# } }} 
											  </ul>
											  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="moreAudioSelect(this, '{{item.db_table}}[{{value.field}}]')">浏览</button>
											</div>
									  </div>
									</div>	
								{{#  }else if(value.input_type == 'document'){ }}
								    <div class="layui-form-item">
									  <input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">	
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											<div>
											  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    
											  {{#  if(value.defaultObj != ''){ }}
											  <li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{value.defaultObj.original}}
											  {{image_input(item.db_table+'['+value.field+']', value.defaultObj)}}
											  <i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:this.parentNode.parentNode.removeChild(this.parentNode);document.getElementById('validation-{{item.db_table}}[{{value.field}}]').value='';">ဆ</i></li>
											  {{# } }} 
											  </ul>
											  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="oneDocumentSelect(this, '{{item.db_table}}[{{value.field}}]')">浏览</button>
											</div>
									  </div>
									</div>	
								{{#  }else if(value.input_type == 'documents'){ }}
								    <div class="layui-form-item">
										<input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">
										<label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
										<div class="layui-input-block">
											<div>
											  <ul class="layui-tab-title" style="border: 1px solid #eee;  min-height:22px; height: auto; overflow: hidden; width:70%;float:left; padding: 8px;">    
												{{#  if(value.defaultObj != ''){ }}
													{{table_input(item.db_table+'['+value.field+']'+"[]", value.defaultObj)}}  
												{{# } }} 
											  </ul>
											  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" onClick="moreDocumentSelect(this, '{{item.db_table}}[{{value.field}}]')">浏览</button>
											</div>
										</div>
									 </div>	
								{{#  }else if(value.input_type == 'date'){ }}
								    <div class="layui-form-item">
										<label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
										<div class="layui-input-block">
											<input data-label="{{value.label}}" type="text" name="{{item.db_table}}[{{value.field}}]"  id="{{item.db_table}}_{{value.field}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layerdate layui-input"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_date(value.default)}}" data-tabinx="{{index}}">
										</div>
									 </div>	 
								{{#  }else if(value.input_type == 'time'){ }}
								    <div class="layui-form-item">
										<label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
										<div class="layui-input-block">
											<input data-label="{{value.label}}" type="text" name="{{item.db_table}}[{{value.field}}]" id="{{item.db_table}}_{{value.field}}"  placeholder="请输入{{value.label}}" autocomplete="off" class="layertime layui-input"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_time(value.default)}}" data-tabinx="{{index}}">
										</div>
									 </div>		
								{{#  }else if(value.input_type == 'checkboxwindow'){ }}
								    <div class="layui-form-item">
									  <input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											<div>
											  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    
												{{#  arr_foreach(value.defaultObj, function(k1, v1){ }}
												<li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{v1.title}}{{window_input(item.db_table+'['+value.field+']'+'[]', v1)}}<i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:if(this.parentNode.parentNode.getElementsByTagName('li').length <= 1){document.getElementById('validation-{{item.db_table}}[{{value.field}}]').value='';};this.parentNode.parentNode.removeChild(this.parentNode);">ဆ</i></li>
												{{#  }); }}				  
											  </ul>
											  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" data-valuetable="{{value.value_table}}"  data-title="{{value.label}}" onClick="moreOpenSelect(this, '{{item.db_table}}[{{value.field}}]')">选择</button>
											</div>
									  </div>
									</div>
								{{#  }else if(value.input_type == 'radiowindow'){ }}
								    <div class="layui-form-item">
									  <input data-label="{{value.label}}" id="validation-{{item.db_table}}[{{value.field}}]" value="{{#  if(value.defaultObj != ''){ }}1{{# } }}"  type="text" style="display: none;"  lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											<div>
											  <ul class="layui-tab-title" style="border: 1px solid #eee;  height:38px; overflow: hidden; width:70%;float:left;">    								
											  {{#  if(value.defaultObj != ''){ }}
											  <li style="border-radius: 2px;height:26px; margin-left: 5px; margin-top:5px;line-height:1.8em;padding: 0 8px;background: #fff;color: #000;" >{{value.defaultObj.title}}
											  {{window_input(item.db_table+'['+value.field+']', value.defaultObj)}}
											  <i class="layui-icon layui-unselect layui-tab-close" onclick="javascript:this.parentNode.parentNode.removeChild(this.parentNode);document.getElementById('validation-{{item.db_table}}[{{value.field}}]').value='';">ဆ</i></li>
											  {{# } }}
											  </ul>
											  <button style="float: left; width: 80px; margin-left: 5px;" type="button" class="layui-btn layui-btn-primary" data-valuetable="{{value.value_table}}" data-title="{{value.label}}" onClick="oneOpenSelect(this, '{{item.db_table}}[{{value.field}}]')">选择</button>
											</div>
									  </div>
									</div>	
								{{#  }else if(value.input_type == 'baidueditor'){ }}
								    <div class="layui-form-item">
									  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
									  <div class="layui-input-block">
											<textarea data-label="{{value.label}}" id="{{value.field}}" name="{{item.db_table}}[{{value.field}}]" placeholder="请输入{{value.label}}" class="layui-textarea baidueditor"  style="width:100%;height:400px;" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" data-tabinx="{{index}}">{{input_default(value.default)}}</textarea>
											
									  </div>
									</div>			
								{{#  }else if(value.input_type == 'file'){ }}
								   <div class="layui-form-item">
								   	<label class="layui-form-label">{{value.label}}</label>
								   	<div class="layui-input-block" style='color:#f00; padding-top: 10px;'>
								   	分步骤表单不支持file组件 请使用document代替
								   	</div>
								   </div>		  
							{{# }else{ }} 
							
							<div class="layui-form-item">
							  <label class="layui-form-label">{{#  if(value.null == 'no'){ }}<span class="required">*</span>{{#  } }}{{value.label}}</label>
							  <div class="layui-input-block">
							    <input data-label="{{value.label}}" type="{{value.input_type}}" name="{{item.db_table}}[{{value.field}}]" id="{{value.field}}"   placeholder="请输入{{value.label}}" autocomplete="off" class="layui-input" lay-verify="{{#  if(value.null == 'no'){ }}required{{#  } }}" value="{{input_default(value.default)}}" data-tabinx="{{index}}">
							  </div>
							</div>
							
							{{# } }} 
							
						{{#  }); }}
					</div>
					{{#  }); }}
				  </div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button type="button" class="layui-btn layui-btn-primary" id="upButton" style="display: none;" >上一步</button>
						<button type="button" class="layui-btn layui-btn-primary" id="nextButton" lay-filter="nextButton">下一步</button>
						<button class="layui-btn" lay-submit lay-filter="formDemo" data-tabindex="0" style="display: none;" id="submitButton">立即提交</button>
					</div>
				</div>
			</form>
			
		</div>
		<script src="/admin/utils/layui/layui.js" charset="utf-8"></script>
		<script src="/admin/utils/layui/config.js" charset="utf-8"></script>
		<script>
			
			window.image_input = function(key, df){
				return "<input class=\"image_input\"  name=\""+key+"\" value='"+json_encode(df)+"' type=\"hidden\"  />";
			}
			
			window.window_input = function(key, df){
				return "<input class='input-hidden' type='hidden' name='"+key+"' value='"+json_encode(df)+"' />";
			}
			window.table_input = function(key, df){
				var tbhtml = '<table class="layui-table">\
				  <thead>\
					<tr>\
						<th width="60%">文件</th>\
						<th>操作</th>\
					</tr>\
				  </thead>\
				  <tbody>';
				for(i in df){
					tbhtml += '<tr>\
							  <td>'+df[i]['original']+image_input(key, df[i])+'</td>\
							  <td><a onclick="cloneMoreDocument(this, \''+key+'\')" href="javascript:void(0)">删除</a></td>\
						  </tr>';
				}
				tbhtml += '</tbody></table>';
				return tbhtml;
			}
			
			window.var_dump = function(text) {
				console.log(text);
				return text;
			}
		
		
		
			layui.use(['layer' ,'laytpl', 'helper', 'formbuilder', 'view', 'element'], function() {
				var laytpl = layui.laytpl;
				var data = eval('(' + $("#menu-data", parent.document).val() + ')');
				var getTpl = document.getElementById('view').innerHTML;
				var view = document.getElementById('view');
				var element = layui.element;
				
				if(data.stepform_fields.length == 1){
					$("#nextButton").css("display","none");
					$("#submitButton").css("display","");
				}
				
				for (i in data['stepform_fields']) {
					if (data['stepform_fields'][i]['db_table'] == '__DB_TABLE__') {
						data.stepform_fields[i]['field'] = data.table_struct.field;
					}
				}
				var stepformData = data;
				var primary_key = data.table_struct['primary_key'];
				ajax_request($_GET['api']+'?_primary_='+$_GET[primary_key]+"&_method=GET", "GET", "" , function(res){
					
					//把值设定到表结构的默认值上
					res = res.data.data[0];
					var editMemuData = data;
					for (i in editMemuData['stepform_fields']) {
						var db_table = data['stepform_fields'][i]['db_table'];
						var fieldItem = data['stepform_fields'][i]['field'];
						//设置默认值了
						for(ii in fieldItem){
							editMemuData['stepform_fields'][i]['field'][ii]['default'] = res[db_table][ii];
							var json = is_json(res[db_table][ii]);
							if(json !== null && json !== false){
								 if(json.length != undefined && json.length > 0){
									 for(iii in json){
										 var jsonItem = is_json(json[iii]);
										 if(jsonItem !== false){
											 json[iii] = jsonItem;
										 }
									 }
								 }
								editMemuData['stepform_fields'][i]['field'][ii]['defaultObj'] = json;
								//json 可能还是一个对象
								
							 }else{
								editMemuData['stepform_fields'][i]['field'][ii]['defaultObj'] = "";
							}
						}
						
					}
					data = editMemuData;
					var getTpl = document.getElementById('view').innerHTML;
					var view = document.getElementById('view');
					laytpl(getTpl).render(editMemuData, function(html) {
						view.innerHTML = html;
							
						//切换tab监听
						element.on('tab(docDemoTabBrief)', function() {
							if (this.getAttribute("data-index") > 0 && this.getAttribute("data-index") < document.getElementById(
									"layui-tab-ul").getElementsByTagName('li').length - 1) {
								document.getElementById("upButton").style.display = '';
								document.getElementById("nextButton").style.display = '';
								document.getElementById("submitButton").style.display = 'none';
							} else if (this.getAttribute("data-index") == 0) {
								document.getElementById("upButton").style.display = 'none';
								document.getElementById("nextButton").style.display = '';
								document.getElementById("submitButton").style.display = 'none';
							} else if (this.getAttribute("data-index") <= document.getElementById("layui-tab-ul").getElementsByTagName(
									'li').length - 1) {
								document.getElementById("upButton").style.display = '';
								document.getElementById("nextButton").style.display = 'none';
								document.getElementById("submitButton").style.display = '';
							}
						});
							
						layui.use(['form', 'laydate', 'parsedata'], function() {
							var laydate = layui.laydate;
							var $ = layui.$;
							var parsedata = layui.parsedata;
							$(".layerdate").each(function(index) {
								laydate.render({
									elem: '#' + this.id //指定元素
								});
							});
							
							//时间输入框
							$(".layertime").each(function(index) {
								laydate.render({
									elem: '#' + this.id, //指定元素
									type: 'datetime'
								});
							});
							
							$(".baidueditor").each(function(index) {
								var ue = UE.getEditor(this.id, {
									autoHeightEnabled: true,
									autoFloatEnabled: true
								});
							});
							setepformButton();
							var form = layui.form;
							form.verify(window.stepFormVerifyConf);
							//监听提交
							form.on('submit(formDemo)', function(data) {
								
								window.submitData = data.field;
								let formdata = stepLayFormData(data, stepformData);
								submit_request($_GET['api'], 'POST', formdata, function(res) {
									let field = stepformData.table_struct.field;
									for(i in res.data){
										if(typeof(parent.window.selectObj.data[i]) != "undefined"){
											var parseFun = field[i]['input_type'];
											var parseOption = field[i]['value'];
											var item =  res.data[i];				
														
											//数组value是关联数组的情况
											try{
												if(parseOption[0]['key']){
													var selectOptions = new Array();//这里就不管他妈的索引不索引的了会排序但不会丢失索引
													for(psi in parseOption){
														var rowOption = parseOption[psi];
														selectOptions[rowOption.key] = rowOption.val;
													}
													parseOption = selectOptions;
												}
											}catch(e){
												//TODO handle the exception
											}
											//、、、				
														
											eval('item = parsedata.'+parseFun+'(item, parseOption);');
											if(in_array(i, ['create_time', 'update_time']) && is_numeric(item) && item > 0 && parseFun == 'hidden'){
												item = formatDate(item * 1000, 'Y-M-D H:i:s');
											}
											parent.window.selectObj.data[i] = item;
										}
									}
									parent.window.selectObj.update(parent.window.selectObj.data);
									noticeMsg('success', "编辑成功");
									parent.layer.closeAll();
								});
								
							});
							
						});
					});
				});
				
				
				
		
			});
		</script>
		
	</body>
</html>
